/**
 * Created by huangchao on 17/11/2017.
 * type：类型：1.普通文本框 2.时间文本框 3.下拉框
 */
import React from 'react'
import {HeiQueryText, HeiQueryCascader, HeiQuerySelect, HeiQueryTime} from '../advancedSearch'
import PropTypes from 'prop-types'

const showHeiQueryItem = (props) => {
  const {data, getFieldProps, select, showCheckout} = props
  if (data.type === 1) { // 普通文本框
    return <HeiQueryText
      select={select}
      showCheckout={showCheckout}
      {...getFieldProps(data.keyword)}
      data={data} />
  }
  if (data.type === 3) { // 下拉框
    return <HeiQuerySelect
      select={select}
      showCheckout={showCheckout}
      {...getFieldProps(data.keyword)}
      data={data} />
  }
  if (data.type === 2) { // 时间文本框
    return <HeiQueryTime
      select={select}
      showCheckout={showCheckout}
      {...getFieldProps(data.keyword)}
      data={data} />
  }
  if (data.type === 4) { // 级联选项
    return <HeiQueryCascader
      select={select}
      showCheckout={showCheckout}
      {...getFieldProps(data.keyword)}
      data={data} />
  }
}

const HeiQueryItem = (props) => {
  return (
    <div>
      {showHeiQueryItem(props)}
    </div>
  )
}

showHeiQueryItem.propTypes = {
  data: PropTypes.object,
  select: PropTypes.func,
  getFieldProps: PropTypes.func,
  showCheckout: PropTypes.any,
}

export default HeiQueryItem
